# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>

pkgname=cargo-edit
pkgver=0.11.9
pkgrel=2
pkgdesc='Managing cargo dependencies from the command line'
url='https://github.com/killercup/cargo-edit/releases'
arch=('loong64' 'x86_64')
license=('MIT' 'APACHE')
depends=('cargo' 'libgit2.so' 'libssh2' 'openssl')
source=(https://github.com/killercup/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('282ddcba19bcd5d4823a96552d81fb9183831472290d2441086af6d4833154acc3e86365c0646fb85a86a562b8fcadd228c8009a51d2a98fbc971fc3cda801cb')
b2sums=('93e2c42048f728f83c71ce14a28479425d2f9f132c9c3cee20aa261be18d01e960420f4ac1ed68ce3095ac84c3351e4c3028f2cb9991a1d243afb19d70da80b8')

prepare() {
  cd "${pkgname}-${pkgver}"
  sed -i '/\"vendored-libgit2\"/d' Cargo.toml
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgname}-${pkgver}
  CFLAGS+=' -ffat-lto-objects'
  LIBSSH2_SYS_USE_PKG_CONFIG=1  cargo build --frozen --release
}

check() {
  cd ${pkgname}-${pkgver}
  # tests depend on target/debug/
  LIBSSH2_SYS_USE_PKG_CONFIG=1 cargo test --frozen
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 \
    target/release/cargo-upgrade \
    target/release/cargo-set-version \
    -t "${pkgdir}/usr/bin"

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
